Repository navigation
[FIX] document_page_reference: avoid duplicate reference on copy and enforce uniqueness - #634
Open
miquelrosell99 wants to merge 2 commits into
Open
miquelrosell99 wants to merge 2 commits into
miquelrosell99 wants to merge 2 commits into
Conversation
Contributor
|
Hi @etobella, |
etobella
approved these changes
Jul 31, 2026
…enforce uniqueness
miquelrosell99
force-pushed
the
18.0-fix-document-page-reference-unique
branch
from
November 2, 2026 07:26
661556f to
3d6e0d8
Compare
Member
|
@miquelrosell99 can you sign the CLA? |
Author
|
Done — I've just signed the OCA Individual CLA. Thanks for the reminder, @etobella! |
The new UNIQUE(reference) SQL constraint fires on the INSERT/UPDATE itself, before the Python @api.constrains check, so duplicate references now raise psycopg2 IntegrityError instead of ValidationError. Update the two pre-existing tests to expect IntegrityError (with mute_logger and the per-test savepoint that TransactionCase provides), following the same pattern as Odoo core tests for SQL constraints.
Author
|
Hi @etobella — the CI issue is fixed (the new SQL constraint fires before the Python check, so the two pre-existing tests now expect IntegrityError, matching core's SQL-constraint test pattern). All checks are green. Could you re-review when you have a moment? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before this fix:
document.pagecopied thereferencevalue as-is, so the new page ended up with the same reference as the original.This fix:
copy=Falseon thereferencefield so copies get a fresh reference generated from the copied page name.reference.